package com.egghiro.framework.j2se.util;

public class Stack<E> {
    private SLinkedList<E> storage = new SLinkedList<E>();

    /*
     * SLinkedList里已经封装了push和pop， 不过为了便于理解本类和Java提供的Stack的不同， 在此还是显示调用addFirst
     */
    public void push(E element) {

        storage.addFirst(element);
    }

    public E peek() {
        return storage.peek();
    }

    public E pop() {
        return storage.removeFirst();
    }

    public boolean isEmpty() {
        return storage.isEmpty();
    }

    public String toString() {
        return storage.toString();
    }

    public int size() {
        return storage.size();
    }
}
